import { Service } from "cl-admin";
import BaseService from "@/service/base";
@Service("audit")
class Reconciliation extends BaseService {
	// 分页列表
	deptList({ size, ...args }) {
		let params = {
			...args,
			page_size: size
		};
		return this.$get("/deptList", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	deptOptions(params) {
		return this.$get("/deptOptions", { params });
	}
	deptEdit(params) {
		return this.$post("/deptEdit", { ...params });
	}
	orderList({ size, timeList, ...args }) {
		let params = {
			...args,
			begin_time: timeList[0],
			end_time: timeList[1],
			page_size: size
		};
		return this.$get("/orderList", { params }).then(res => {
			if (params.no_page) {
				console.log(res, "res");
				return res;
			} else {
				return {
					list: res.data,
					pagination: {
						...params,
						size,
						total: res.total
					}
				};
			}
		});
	}
	orderEdit(params) {
		return this.$post("/orderEdit", { ...params });
	}
	orderClose(params) {
		return this.$post("/orderClose", { ...params });
	}
	orderAdd(params) {
		return this.$post("/orderAdd", { ...params });
	}
	orderCheck(params) {
		return this.$post("/orderCheck", { ...params });
	}
	deptReportTotal({ params, timeList, ...args }) {
		let params2 = {
			...args,
			begin_time: timeList[0],
			end_time: timeList[1]
		};
		return this.$post("/deptReport", { ...params2 });
	}
	payMethodsList({ size, ...args }) {
		let params = {
			...args,
			page_size: size
		};
		return this.$get("/deptPaymentWay/lists", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	deptPaymentWayNoPage({ ...args }) {
		let params = {
			...args,
			page: 0
		};
		return this.$get("/deptPaymentWay/lists", { params }).then(res => {
			return res;
		});
	}
	addDeptPaymentWay(params) {
		return this.$post("/deptPaymentWay/add", params);
	}
	editDeptPaymentWay(params) {
		return this.$post("/deptPaymentWay/edit", params).then(res => {
			return {
				...res
			};
		});
	}
	deptAllocationPlanList({ size, hasPage, ...args }) {
		let params;
		if (!hasPage) {
			params = {
				...args,
				page: 0
			};
		} else {
			params = {
				...args,
				page_size: size
			};
		}
		return this.$get("/DeptAllocationPlan/lists", { params }).then(res => {
			if (!hasPage) {
				return res;
			} else {
				return {
					list: res.data,
					pagination: {
						...params,
						size,
						total: res.total
					}
				};
			}
		});
	}
	addDeptAllocationPlan(params) {
		return this.$post("/DeptAllocationPlan/add", params).then(res => {
			return {
				...res
			};
		});
	}
	editDeptAllocationPlan(params) {
		return this.$post("/DeptAllocationPlan/edit", params).then(res => {
			return {
				...res
			};
		});
	}
	// 结算订单列表
	closedList({ size, timeList, ...args }) {
		let params2 = {
			...args,
			begin_time: timeList[0],
			end_time: timeList[1],
			page_size: size
		};
		console.log(params2, "params2");

		return this.$get("/closedList", { params: params2 }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params2,
					size,
					total: res.total
				}
			};
		});
	}
	// 付款
	closedPaid(params) {
		return this.$post("/closedPaid", params).then(res => {
			return {
				...res
			};
		});
	}
	closedRollback(params) {
		return this.$post("/closedRollback", params).then(res => {
			return {
				...res
			};
		});
	}
	updatePaymentWay(params) {
		return this.$post("/updatePaymentWay", params).then(res => {
			return {
				...res
			};
		});
	}
	//对账删除
	orderDel(params) {
		return this.$post("/orderDel", params).then(res => {
			return {
				...res
			};
		});
	}
	reconciliationList({ size, timeList, ...args }) {
		let params = {
			...args,
			begin_time: timeList[0],
			end_time: timeList[1],
			page_size: size
		};
		return this.$get("/cashierReconciliation/lists", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	reconciliationDel(params) {
		return this.$post("/cashierReconciliation/delete", params).then(res => {
			return {
				...res
			};
		});
	}
}
export default Reconciliation;
